package com.kk.player;

import android.database.Cursor;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.ListFragment;
import android.support.v4.view.ViewPager;
import android.view.Menu;

public class TrackBrowser extends FragmentActivity {
	Cursor musiccursor;
	int music_column_index;
	int count;
	MediaPlayer mMediaPlayer;
	ListFragment trackList;
    SectionsPagerAdapter mSectionsPagerAdapter;
    ViewPager mViewPager;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.track_browser);
        // Create the adapter that will return a fragment for each of the three primary sections
        // of the app.
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());


        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mSectionsPagerAdapter);
       
		mMediaPlayer = new MediaPlayer();

    }
    
   

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.track_browser, menu);
        return true;
    }
    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int i) {
        	Fragment fragment = new DummySectionFragment();
    		Bundle args = new Bundle();
    		args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
    		fragment.setArguments(args);
        	switch(i){
        		case 2: 
                		return fragment;
        		case 1: Fragment trackListFragment = new TrackListFragment();
		        		Bundle args1 = new Bundle();
		        		args1.putInt(TrackListFragment.ARG_SECTION_NUMBER, i + 1);
		        		trackListFragment.setArguments(args1);
		        		return trackListFragment;
        	}
			return fragment;
            
        }

        @Override
        public int getCount() {
            return 3;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0: return getString(R.string.title_section1).toUpperCase();
                case 1: return getString(R.string.title_section2).toUpperCase();
                case 2: return getString(R.string.title_section3).toUpperCase();
            }
            return null;
        }
    }
    
    
   
}
